import React from 'react';
import ReactDOM from 'react-dom/client';
import { BrowserRouter, HashRouter } from 'react-router-dom';
import { Provider } from 'react-redux';
import '@/styles/main.less';
import App from './App';
import store from '@/store/index';
import LoadingIndicator from '@/components/LoadingIndicator';
import useMicroApp from './hooks/microApp/useMicroApp';

// 为 createRoot 提供正确的类型
const rootElement = document.getElementById('root');
if (rootElement) {
  const root = ReactDOM.createRoot(rootElement);
  root.render(
    <React.StrictMode>
      <BrowserRouter>
        <Provider store={store}>
          <LoadingIndicator />
          <App />
        </Provider>
      </BrowserRouter>
    </React.StrictMode>
  );
  useMicroApp();
} else {
  console.error('未能找到根元素 #root');
}
